<?php

/*

  Action	$7
  You may choose an Action card in your hand. Play it three times.

 */

class KingsCourt extends Card implements iAction, iKingdom, iProsperity {

    public function __construct() {
        parent::__construct("Kings Court", 7);
        $this->undoPlay = false;
        $this->undoBuy = true;
    }

    public function getDescription() {
        return array(
            "You may choose an Action card in your hand. Play it three times.");
    }
    
    public function play(Game $game, $isRealCard) {


        $playHand = $game->getPlayHand();
        $action_cards = array();
        foreach ($playHand as $card) {
            if ($card instanceof iAction) {
                $action_cards[] = $card;
            }
        }

        if (sizeof($action_cards) > 0) {
            
            $action_cards = getUniqueCards($action_cards);
            if (sizeof($action_cards) > 1) {
                $output = MySocket::GetUserReply($game, Input_ChooseOne, $action_cards, 1, 1, null, "Choose a card for kings court");
                $card_name = $output[0];
            } else {
                $card_name = $action_cards[0];
            }
            
            $card = $game->moveCardFromPileToPile($card_name, PlayHand, PlayArea);

            ScreenDisplay::addScreenMessage($game, true, "play ".  nicePrint($card). " three times", " plays ". ScreenDisplay::$LMSG. " three times");
            
            $game->pushCardToStack($card, REAL_CARD);
            $game->pushCardToStack($card, VIRTUAL_CARD);
            $game->pushCardToStack($card, VIRTUAL_CARD);
        }
        $game->cardActionFinished();
        return true;
    }

}

?>